<template>
    <div class="setinfo">
        <nav-bar>修改个人昵称<template #my> <span @click="cun">保存</span></template></nav-bar>
        <div class="con">
            <van-cell-group>
                <van-field v-model="nickname"  />
            </van-cell-group>
        </div>
    </div>
</template>

<script>
import { putUser, getUserInfo } from "@/http/login"
export default {
    data() {
        return {
            nickname: '',
        }
    },
    created(){
        this.getUserInfo()
    },
    methods: {
     async getUserInfo(){
            let res = await getUserInfo()
            console.log(res);
            this.nickname = res.data.nickname

        },
        async putUser(){
            let res = await putUser({ nickname: this.nickname })
            this.$router.back()
        },
        cun(){
          this.putUser()
      }
    }
}
</script>

<style lang="scss" scoped>
.con {
    margin-top: 8vh;
}
</style>
